package io.gitee.sfch.chunmi.controller.system;

import io.gitee.sfch.chunmi.entity.Pageable;
import io.gitee.sfch.chunmi.entity.Pagination;
import io.gitee.sfch.chunmi.entity.Response;
import io.gitee.sfch.chunmi.controller.system.form.SystemUserAddForm;
import io.gitee.sfch.chunmi.controller.system.request.SystemUserPageRequest;
import io.gitee.sfch.chunmi.dao.system.entity.SystemUser;
import io.gitee.sfch.chunmi.service.system.SystemUserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 系统用户控制层
 */
@RestController
@RequestMapping("/system/user")
public class SystemUserController {

    @Resource
    private SystemUserService systemUserService;

    /**
     * 分页查询
     */
    @GetMapping("/findPage")
    public Response<Pagination<SystemUser>> findPage(SystemUserPageRequest pageRequest, Pageable pageable) {
        Pagination<SystemUser> page = systemUserService.findPage(pageRequest, pageable);
        return Response.success(page);
    }

    /**
     * 新增用户
     */
    @PostMapping("/add")
    public Response<String> addUser(@RequestBody SystemUserAddForm addForm) {
        systemUserService.add(addForm);
        return Response.successEmpty(null);
    }
}
